
function m() {
    function Creat() {
        this.d = new Date()
        this.$img = $(' #Floor').find('img');
        this.hover()
        //			头部二级导航栏的选择
        this.$box = $('.bottom-stair').find('.stair-a');
        this.$bigbox = $('.banner').find('.banner-list');
        this.$floor = $('#Floor');
        this.init();
    }
    Creat.prototype.hover = function(){
        this.$img.hover(function () {
            $(this).addClass("hover")
        },function () {
            $(this).removeClass("hover")
        })

    }
    

    Creat.prototype.bindEventList = function (res){
        $('#Floor').on('click', '.gwc-shop',function(){
            const id = $(this).parent('li').attr("index");
            console.log(id);
            // console.log(res);
             for(var i in res ){
                for (var k in res[i].RfloorALL){
                    if(  res[i].RfloorALL[k].id === id){
                        console.log(res[i].RfloorALL[k]);
                        let data = JSON.stringify(res[i].RfloorALL[k])
                        console.log(data);
                        localStorage.setItem('Detail' + res[i].RfloorALL[k].id, data);
                         location.href='http://localhost:3000/dist/list.html?id='+id;
                         return true;
                    }
                }
                } throw 'id is Empty or Not Find!'
    } )
    }
    

    Creat.prototype.init = function () {
        var that = this;
        $.ajax({
            type: 'get',
            url: 'http://localhost:3000/static/data/GeliFloorA.json',
            success: function (res) {
                that.dispFloor(res);
               
                that.bindEventList(res);
            },
            error: function () {
                console.log(404)
            }
        })
    }
 
    Creat.prototype.display = function (res) {
        var str, div, dl, dt, dd;
        str = "";
        div = "";
        dl = "";
        dd = "";
        for (var i in res) {
            for (var j in res[i].content) {
                var list = res[i].content[j];
                for (var k in list.content) {
                    dd += `<dd>
                            <b><a href="#" target="_blank">${list.content[k]}</a></b>
                        </dd>`
                }
                dl += `<dl>
                        <dt><a href="#" target="_blank">${list.title}</a></dt>
                        ${dd}
                    </dl>`
                dd = '';
            }
            str += `<li>
                    <a href="#javascript" class="dh">${res[i].title}</a>
                  </li>
                  <div class="banner-div" pref=${i-0+1} style="display: none;">
                    <div class="banner-title" style="height: auto;">${dl}</div>
                </div>`;
            dl = "";
        }
        this.$box.html(str);
        this.myEvent();
    }
    Creat.prototype.dispFloor = function (res) {
        var str, Lali, Rfli;
        str = '';
        Lali = '';
        Rfli = '';
        for (var i in res) {
            for (var j in res[i].FloorTListcon) {
                Lali += `<li>
                        <a href="#">${res[i].FloorTListcon[j]}</a>
                    </li>`;
                     
            }
            for (var k in res[i].RfloorALL) {
                var Rf = res[i].RfloorALL;
               
                Rfli += `	<li index=${Rf[k].id} class="list-id">
                        <a href="#" class="gwc-shop">
                        <img data-src="${Rf[k].src}"title="${Rf[k].title}"/>
                        <span class="gouwuche">点击查看</span>
                        </a>
                        <a href="#" class="over_ell">${Rf[k].title}</a>
                        <a href="#" class="over_ell">${Rf[k].nameads}</a>
                        <label class="over_ell">${Rf[k].price}</label>
                    </li>`
            }
            str += `<div class="c"></div>
                    <div class="floor" name='floor${i-0+1}'>
                        <div class="floor_nav">
                            <p>${res[i].FloorTList}</p>
                            <ul class="floor_nav-list" id="${i-0+1}">
                                    ${Lali}
                            </ul>
                        </div>
                        
                        <div class="floor_right">
                            <ul id="floorId${parseInt(Math.random()*1000)}">
                                <li style="width: 290px;height: 748px; margin-right: 11px ;>
                                    <a href="#"><img data-src="${res[i].R1Img}"alt="" title="${res[i].R1Title}"/>
                                      
                                    </a>
                                </li>
                                ${Rfli}
                            </ul>
                        </div>
                    </div>`;
            Lali = '';
            Rfli = ''
        }
       
        setTimeout(() => {
            this.$floor.append(str);
            new lazyLoad("#Floor img")
       }, 300);
        this.$img = $(" #Floor li a img");
        this.$span =$("#Floor li a span ");
        this.hover()
    }
    // li增加阴影
    Creat.prototype.myEvent = function () {
        this.$box.on("mouseenter", 'li', function () {
            var ind = $(this).index() / 2;
            this.$box.children('div').eq(ind).css('display', 'block').siblings('div').css('display', "none");
        })
        this.$bigbox.on('mouseleave', this.$box.find('div'), function () {
            this.$box.children('div').css('display', 'none');
        })
    }
    
    new Creat();
}
m();